<?xml version="1.0" encoding="UTF-8"?>
<ui:component xmlns="http://www.w3.org/1999/xhtml"
	xmlns:fn="http://java.sun.com/jsp/jstl/functions"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">
	
	<ui:composition template="/pages/templates/layout_principal.xhtml">
		<ui:define name="message">
			<rich:messages globalOnly="true" showSummary="true" showDetail="true" />
		</ui:define>
		
		<ui:define name="body" width="100%">
			<h:form>
				<h:panelGrid styleClass="titulo">
					<h:outputText styleClass="titulo" value="#{acompanharProjetoControl.projeto.nome} - Acompanhamento" />
				</h:panelGrid>
				
				<br />
				<rich:panel id="resumo" header="Resumo do Projeto">
					<h:panelGrid columns="2">
						<h:outputText value="Início (Estimado - Realizado):" style="font-weight: bold;" />
						<h:panelGroup>
							<h:outputText value="#{acompanharProjetoControl.projeto.inicio}">
								<f:convertDateTime pattern="dd/MM/yyyy" />
							</h:outputText>
							 - 
							<h:outputText value="#{acompanharProjetoControl.projeto.inicioRealizado}">
								<f:convertDateTime pattern="dd/MM/yyyy" />
							</h:outputText>
						</h:panelGroup>
						
						<h:outputText value="Fim (Estimado - Realizado):" style="font-weight: bold;" />
						<h:panelGroup>
							<h:outputText value="#{acompanharProjetoControl.projeto.fim}">
								<f:convertDateTime pattern="dd/MM/yyyy" />
							</h:outputText>
							 - 
							<h:outputText value="#{acompanharProjetoControl.projeto.fimRealizado}">
								<f:convertDateTime pattern="dd/MM/yyyy" />
							</h:outputText>
						</h:panelGroup>
						
						<h:outputText value="Horas (Estimado - Realizado):" style="font-weight: bold;" />
						<h:panelGroup>
							<h:outputText value="#{acompanharProjetoControl.projeto.horasEstimadas} horas" />
							 - 
							<h:outputText value="#{acompanharProjetoControl.projeto.horasRealizadas} horas" />
						</h:panelGroup>
						
						<h:outputText value="Situação:" style="font-weight: bold;" />
						<h:outputText value="#{acompanharProjetoControl.projeto.situacao.descricao}" />
						
						<h:outputText value="Iteração Corrente:" style="font-weight: bold;" />
						<h:panelGroup>
							<h:commandLink value="#{acompanharProjetoControl.iteracaoCorrente.fase.nome} - ##{acompanharProjetoControl.iteracaoCorrente.numero}" 
								action="#{acompanharProjetoControl.visualizarIteracao}" rendered="#{acompanharProjetoControl.iteracaoCorrente ne null}">
							<f:setPropertyActionListener target="#{acompanharProjetoControl.idIteracaoSelecionada}" value="#{acompanharProjetoControl.iteracaoCorrente.id}"/>
						</h:commandLink>
						</h:panelGroup>
					</h:panelGrid>
				</rich:panel>
				
				<br/>
				
				<rich:dataTable var="iteracao" value="#{acompanharProjetoControl.iteracoes}" styleClass="stable">
					<f:facet name="header">
						<rich:column colspan="7">Iterações</rich:column>
						<rich:columnGroup>
							<rich:column breakRowBefore="true" style="width: 15%">
								Fase/ Núm.
							</rich:column>
							<rich:column>
								Nome
							</rich:column>
							<rich:column style="width: 10%">
								Início
							</rich:column>
							<rich:column style="width: 10%">
								Fim
							</rich:column>
							<rich:column style="width: 16%">
								Situação
							</rich:column>
							<rich:column>
								Gantt
							</rich:column>
						</rich:columnGroup>
					</f:facet>
					
					<rich:column>
						<h:commandLink value="#{iteracao.fase.nome} - ##{iteracao.numero}" title="Detalhes da Iteração" 
							action="#{acompanharProjetoControl.visualizarIteracao}">
							<f:setPropertyActionListener target="#{acompanharProjetoControl.idIteracaoSelecionada}" value="#{iteracao.id}"/>
						</h:commandLink>
					</rich:column>
					<rich:column>
						#{iteracao.nome}
					</rich:column>
					<rich:column>
						<h:outputText value="#{iteracao.inicio}">
							<f:convertDateTime pattern="dd/MM/yyyy" />
						</h:outputText>
					</rich:column>
					<rich:column>
						<h:outputText value="#{iteracao.fim}">
							<f:convertDateTime pattern="dd/MM/yyyy" />
						</h:outputText>
					</rich:column>
					<rich:column>
						#{iteracao.situacao.descricao}
					</rich:column>
					<rich:column style="text-align: center;">
						<a4j:commandLink render="panelGantt" execute="@this"
							oncomplete="#{rich:component('panelGantt')}.show()">
							<a4j:param assignTo="#{gerarGanttControl.idIteracao}" value="#{iteracao.id}" />
							<h:graphicImage library="images" name="chart_line.png" title="Visualizar Gantt" />
						</a4j:commandLink>
					</rich:column>
				</rich:dataTable>
				
				
				<ui:include src="/pages/projeto/_gantt.xhtml" />
			</h:form>
			
			<rich:jQuery selector=".stable tr" event="mouseover" query="jQuery(this).addClass('active-row')" />
			<rich:jQuery selector=".stable tr" event="mouseout" query="jQuery(this).removeClass('active-row')" />
			
		</ui:define>
		
		<rich:jQuery selector=".stable tr:odd" query="addClass('odd-row')" />
		<rich:jQuery selector=".stable tr:even" query="addClass('even-row')" />
	</ui:composition>
</ui:component>